package Array;

import org.junit.Test;

/**
 * @BelongsProject: SeniorArchitect-LeetCode
 * @BelongsPackage: Array
 * @Author: zhuangxiaoyan
 * @CreateTime: 2023-10-18  16:58
 * @Description: TODO
 * @Version: 1.0
 */
public class 买卖股票的最佳时机II122 {

    public int maxProfit(int[] prices) {
        int len=prices.length;
        int max=0;
        for (int i=1;i<prices.length;i++){
            if (prices[i]>prices[i-1]){
                max=Math.max(max,max+prices[i]-prices[i-1]);
            }
        }
        return max;
    }

    @Test
    public void test(){
        int i = maxProfit(new int[]{7, 1, 5, 3, 6, 4});
        System.out.println(i);
    }
}
